Debugging and Profiling

Debugging

Logging

Logging is better than regular print statements for several reasons:

logger "Hello Logs"

log show --last 1m | grep Hello
# On Linux
journalctl --since "1m ago" | grep Hello

Debuggers

Specialized Tools

  # On Linux
  sudo strace -e lstat ls -l > /dev/null
  4
  # On macOS
  sudo dtruss -t lstat64_extended ls -l > /dev/null

- look at the network packets

- Tools like tcpdump and Wireshark are network packet analyzers

- For web development, the Chrome/Firefox developer tools

Static Analysis

Profiling

Since premature optimization is the root of all evil, you should learn about profilers and monitoring tools.